package com.wangzhip.bean;


import lombok.Data;
import org.springframework.beans.BeansException;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

@Data
@EnableConfigurationProperties(CartoonProperties.class)
public class CarttoonCatAndMouseAutoConfig implements ApplicationContextAware {

    private Cat cat;
    private Mouse mouse;
    private CartoonProperties cartoonProperties;

    public CarttoonCatAndMouseAutoConfig(CartoonProperties cartoonProperties) {
        this.cartoonProperties = cartoonProperties;

        System.out.println("================");
        System.out.println(cartoonProperties);
        System.out.println("================");
//        System.out.println(mouse);
    }

    public void play(){
        String[] beanDefinitionNames = this.applicationContext.getBeanDefinitionNames();

        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
    }
    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

        this.applicationContext=applicationContext;
    }
}
